package lesson15;


public class Car {
	String model;
	double maxSpeed;
	double currentSpeed;
	String color;
	int currentGear;
	Person owner;
	double price;
	boolean isSportsCar;

	// Car()
	// {
	// this.isSportsCar = false;
	// }

	Car(String model) {
		// this();
		this.model = model;
	}

	Car(String model, String color, boolean isSportsCar) {
		this(model);
		this.isSportsCar = isSportsCar;
		this.color = color;
		currentSpeed = 10;
		currentGear = 1;
	}

	Car(String model, boolean isSportsCar, String color, double price,
			double maxSpeed) {
		this(model, color, isSportsCar);
		this.price = price;
		if (maxSpeed > 200) {
			if (isSportsCar) {
				this.maxSpeed = maxSpeed;
			}
		} else {
			this.maxSpeed = maxSpeed;
		}
	}

	void printCar() {
		System.out.println("Model: " + model);
		System.out.println("Is sports car:" + isSportsCar);
		System.out.println("Color: " + color);
		System.out.println("Price: " + price);
		System.out.println("Maximum speed: " + maxSpeed);
	}

	boolean isMoreExpensive(Car car) {
		/*
		 * if (this.price > car.price) return true; else return false;
		 */

		return (this.price > car.price);
	}

	double calculateCarPriceForScrap(double metalPrice) {
		double coef = 0.2;
		if (this.color.equalsIgnoreCase("black")
				|| this.color.equalsIgnoreCase("white")) {
			coef += 0.05;
		}
		if (this.isSportsCar) {
			coef += 0.05;
		}

		return metalPrice * coef;
	}
	
	void changeOwner(Person newOwner)
	{
		this.owner = newOwner;
	}

	void accelerate(int speedUp) {
		currentSpeed += speedUp;
	}

	void changeGearUp() {
		if (currentGear < 5)
			currentGear++;
	}

	void changeGearDown() {
		if (currentGear > 1)
			currentGear--;
	}

	void changeGear(int nextGear) {
		if (nextGear >= 1 && nextGear <= 5)
			currentGear = nextGear;
	}

	void changeColor(String newColor) {
		color = newColor;
	}
}
